<?php
/**
 * Created by PhpStorm.
 * User: sykbxc
 * Date: 2019-03-03
 * Time: 18:59
 */
namespace App\Services\LogServices;


use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\FirePHPHandler;

class MyLog
{

    public static function writeToLog($message, $filename)
    {
        $path = storage_path($filename . '-' . date('Y-m-d') . '.log');
        $logger = new Logger('datacache');
        $logger->pushHandler(new StreamHandler($path, Logger::INFO));
        $logger->pushHandler(new FirePHPHandler());
        $message = is_string($message) ? $message : json_encode($message, JSON_UNESCAPED_UNICODE);
        $logger->info($message);
    }
}